import request from "../utils/request";

export const loginService = (id, password) => {
    const params = new URLSearchParams()
    params.append('id', id)
    params.append('password', password)
    return request.put("/user/login", params)
}

export const findByIdService = (id) => {
    const params={'id':id}
    return request.get("/user/findById", {params:params})
}


export const updatePasswordService = (form) => {
    const params = new URLSearchParams()
    for(let key in form){
        params.append(key,form[key])
    }
    return request.post("/user/findPassword", params)
}

export const registerService = (form) => {
    const params = new URLSearchParams()
    for(let key in form){
        params.append(key,form[key])
    }
    return request.post("/user/insertUser", params)
}

export const getAllUserService = (pageNum,pageSize) => {
    const params={'pageNum':pageNum,'pageSize':pageSize}
    return request.get("/user/getAllUser", {params:params})
}

export const updateStateService = (id) => {
    const params = new URLSearchParams()
    params.append('id', id)
    return request.put("/user/updateState",params)
}

export const silenceService = (id,minute) => {
    const params = new URLSearchParams()
    params.append('id', id)
    params.append('minute', minute)
    return request.put("/user/silence", params)
}

export const suspendService = (id,minute) => {
    const params = new URLSearchParams()
    params.append('id', id)
    params.append('minute', minute)
    return request.put("/user/suspend",params)
}

export const userInfoService = () => {
    return request.get("/user/info")
}

export const updateUserService = (form) => {
    const params = new URLSearchParams()
    for(let key in form){
        params.append(key,form[key])
    }
    return request.post("/user/updateUser", params)
}

export const newTokenService = () => {
    return request.get("/user/newToken")
}


// export const tLoginService = (id, password) => {
//     const params = new URLSearchParams()
//     params.append('userId', id)
//     params.append('password', password)
//     return request.put("/login/teacherLogin", params)
// }